import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render, formattingMin, formattingDay } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	{
		title: '商户类型。旅游公司；汽车公司；景点；酒店宾馆',
		align: "center",
		dataIndex: 'type_dictText'
	},
	{
		title: '租户ID',
		align: "center",
		dataIndex: 'tenantid_dictText'
	},
	{
		title: '商家名称',
		align: "center",
		dataIndex: 'shoptitle'
	},
	{
		title: '联系电话',
		align: "center",
		dataIndex: 'concacttel'
	},
	{
		title: '地址',
		align: "center",
		dataIndex: 'address'
	},
	{
		title: '封面图片',
		align: "center",
		dataIndex: 'cover',
		customRender: render.renderImage,
	},
	{
		title: '介绍',
		align: "center",
		dataIndex: 'description'
	},
	{
		title: '其余属性',
		align: "center",
		dataIndex: 'extinfors'
	},
];
//查询数据
export const searchFormSchema : FormSchema[] = [
	{
		label: "商户类型。旅游公司；汽车公司；景点；酒店宾馆",
		field: "type",
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "shop_type"
		},
		//colProps: {span: 6},
	},
	{
		label: "租户ID",
		field: "tenantid",
		component: 'JSearchSelect',
		componentProps: {
			dict: "sys_tenant,name,id"
		},
		//colProps: {span: 6},
	},
	{
		label: "联系电话",
		field: "concacttel",
		component: 'Input',
		//colProps: {span: 6},
	},
];

//表单数据
export const formSchema : FormSchema[] = [
	{
		label: '商户类型。旅游公司；汽车公司；景点；酒店宾馆',
		field: 'type',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "shop_type"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入商户类型。旅游公司；汽车公司；景点；酒店宾馆!' },
			];
		},
	},
	{
		label: '租户ID',
		field: 'tenantid',
		component: 'JSearchSelect',
		componentProps: {
			dict: "sys_tenant,name,id"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入租户ID!' },
			];
		},
	},
	{
		label: '商家名称',
		field: 'shoptitle',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入商家名称!' },
			];
		},
	},
	{
		label: '联系电话',
		field: 'concacttel',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入联系电话!' },
			];
		},
	},
	{
		label: '地址',
		field: 'address',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入地址!' },
			];
		},
	},
	{
		label: '封面图片',
		field: 'cover',
		component: 'JImageUpload',
		componentProps: {
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入封面图片!' },
			];
		},
	},
	{
		label: '介绍',
		field: 'description',
		component: 'InputTextArea',//TODO 注意string转换问题
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入介绍!' },
			];
		},
	},
	{
		label: '其余属性',
		field: 'extinfors',
		component: 'InputTextArea',//TODO 注意string转换问题
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其余属性!' },
			];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];

//子表列表数据
export const bsBasiclayoutShopbinddealerColumns : BasicColumn[] = [
	{
		title: '绑定状态',
		align: "center",
		dataIndex: 'stats_dictText'
	},
	{
		title: '商家ID',
		align: "center",
		dataIndex: 'shopid_dictText'
	},
	{
		title: '用户ID',
		align: "center",
		dataIndex: 'userid_dictText'
	},
];
//子表表单数据
export const bsBasiclayoutShopbinddealerFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '绑定状态',
		field: 'stats',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "shop_bind_dealer_status"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入绑定状态!' },
			];
		},
	},
	{
		label: '商家ID',
		field: 'shopid',
		component: 'JSearchSelect',
		componentProps: {
			dict: "bs_basiclayout_shop,shopTitle,id"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入商家ID!' },
			];
		},
	},
	{
		label: '用户ID',
		field: 'userid',
		component: 'JSearchSelect',
		componentProps: {
			dict: "bs_userlayout_userinfor,nickName,id"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入用户ID!' },
			];
		},
	},
];
//子表列表数据
export const coupleShopPdtColumns : BasicColumn[] = [
	{
		title: '发布时间',
		align: "center",
		dataIndex: 'createTime'
	},
	{
		title: '标题',
		align: "center",
		dataIndex: 'title'
	},
	{
		title: '市场价',
		align: "center",
		sorter: true,
		dataIndex: 'deduction'
	},
	{
		title: '售价',
		align: "center",
		sorter: true,
		dataIndex: 'price'
	},
	{
		title: '商家',
		align: "center",
		dataIndex: 'shopId_dictText'
	},
	{
		title: '销量',
		align: "center",
		sorter: true,
		dataIndex: 'salesQuantity'
	},
	{
		title: '已核销',
		align: "center",
		sorter: true,
		dataIndex: 'cancelledNum'
	},
	{
		title: '超时未核销',
		align: "center",
		sorter: true,
		dataIndex: 'uncancelledNum'
	},
	{
		title: '过期时间',
		align: "center",
		sorter: true,
		dataIndex: 'expirationTime'
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId'
	},
];
//子表表单数据
export const coupleShopPdtFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '标题',
		field: 'title',
		component: 'Input',
	},
	{
		label: '市场价',
		field: 'deduction',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: false },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '售价',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: false },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '商家',
		field: 'shopId',
		component: 'JSearchSelect',
		componentProps: {
			dict: "couple_shop,title,id"
		},
	},
	{
		label: '过期时间',
		field: 'expirationTime',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
	},
];
//子表列表数据
export const coupleShopOrderColumns : BasicColumn[] = [
	{
		title: '订单状态',
		align: "center",
		dataIndex: 'orderStatus_dictText'
	},
	{
		title: '商品',
		align: "center",
		dataIndex: 'pdtId_dictText'
	},
	{
		title: '金额',
		align: "center",
		sorter: true,
		dataIndex: 'price'
	},
	{
		title: '下单用户',
		align: "center",
		dataIndex: 'userId_dictText'
	},
	{
		title: '核销状态',
		align: "center",
		dataIndex: 'chargeOffStatus_dictText'
	},
	{
		title: '核销用户',
		align: "center",
		dataIndex: 'chargeOffUser_dictText'
	},
	{
		title: '过期时间',
		align: "center",
		dataIndex: 'expirationTime'
	},
	{
		title: '核销时间',
		align: "center",
		dataIndex: 'chargeOffTime'
	},
	{
		title: '商家',
		align: "center",
		dataIndex: 'shopId_dictText'
	},
];
//子表表单数据
export const coupleShopOrderFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '订单状态',
		field: 'orderStatus',
		component: 'JSearchSelect',
		componentProps: {
			dict: "sys_category,name,id"
		},
	},
	{
		label: '过期时间',
		field: 'expirationTime',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
	},
];
//子表列表数据
export const bsHotelroompriceColumns : BasicColumn[] = [
	/*  {
	   title: 'trash',
	   align:"center",
	   dataIndex: 'trash'
	  }, */
	{
		title: '级别类型',
		align: "center",
		dataIndex: 'leveltype_dictText'
	},
	{
		title: '几天总费用',
		align: "center",
		dataIndex: 'daynum'
	},
	{
		title: '房价金额',
		align: "center",
		dataIndex: 'price'
	},
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender:({text})=>{
			return formattingMin(text)
		}
	},
	{
		title: '图片',
		align: "center",
		dataIndex: 'images',
		customRender: render.renderImage,
	},
];
//子表表单数据
export const bsHotelroompriceFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	/* {
	   label: 'trash',
	   field: 'trash',
	   component: 'Input',
	   dynamicRules: ({model,schema}) => {
			 return [
					{ required: true, message: '请输入trash!'},
			 ];
		},
	 }, */
	{
		label: '级别类型',
		field: 'leveltype',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "leveltype"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择级别类型' },
			];
		},
	},
	{
		label: '几天总费用',
		field: 'daynum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入几天总费用!' },
				{ pattern: /^-?\d+$/, message: '请输入整数!' },
			];
		},
	},
	{
		label: '房价金额',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入房价金额!' },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '图片',
		field: 'images',
		component: 'JImageUpload',
		componentProps: {
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请上传图片!' },
			];
		},
	},
];